function [classAmount] = Classificator( directory, waituser )
%Classsificator: Gets a file directory and classifies its images

disp('Start training');

[Means,Radiuses] = TrainingFunc('training');

disp('Training finished');
disp('-----------------------------------------------');

pictures = dir([directory,'/*.jpeg']);

classNames = {'Boys','Girls','Undefined'};

classAmount = [0,0,0];

for i=1:length(pictures)
    featureVec = FeatureExtraction([directory,'/',pictures(i).name]);
    
    distances = zeros(1,length(Means(:,1)));
    
    for j=1:length(Means(:,1))
        vec = featureVec - Means(j,:);
        distance = norm(vec);
        
        if Radiuses(j) > distance
            distances(j) = distance;
        else
            distances(j) = 999;
        end
    end
    
    if sum(distances <= 100) ~= 0
        classified = find(distances == min(distances));
    else
        classified = 3;
    end
    
    disp([pictures(i).name,' classified as ',classNames{classified}]);
    classAmount(classified) = classAmount(classified)+1;
    
    if waituser
        imshow(imread([directory,'/',pictures(i).name]));
        text(10,20,classNames{classified},'fontsize',50,'color','black','Background','white');
        waitforbuttonpress;
    end
end

end

